﻿using System.Text;

namespace Sharp.Portal.AdminLTE.FormField
{
    /// <summary>
    /// 文本域控件
    /// </summary>
    public class TextAreaField : ElementField
    {
        /// <summary>
        /// 文本域控件
        /// </summary>
        /// <param name="fieldName"></param>
        public TextAreaField(string fieldName)
        {
            this.FieldName = fieldName;
        }
        /// <summary>
        /// 生成
        /// </summary>
        /// <param name="nonFirst"></param>
        /// <returns></returns>
        public override string Build(bool nonFirst = false)
        {
            if (this.IsBrowsing() && !this.KeepingXType)
            {
                return $"@Html.Bootstrap().LableFor(m => m.{this.FieldName})" + base.Build(nonFirst);
            }

            var sb = new StringBuilder();
            sb.AppendFormat("@Html.Bootstrap().TextareaFor(m => m.{0})", FieldName);
            sb.AppendFormat("@Html.ValidationMessageFor(m => m.{0})", FieldName );

            return sb.ToString();
        }
    }
}
